package cn.com.bluemoon.daps.system.controller;

import cn.com.bluemoon.daps.common.datascope.BmPermission;
import cn.com.bluemoon.daps.common.datascope.IgnorePermission;
import cn.com.bluemoon.daps.common.domain.UserInfoHolder;
import cn.com.bluemoon.daps.domp.api.LocalUserService;
import cn.com.bluemoon.daps.system.service.impl.LocalUserServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Collections;
import java.util.List;
import java.util.Map;

/**
 * @author Lilike on 2023/1/2
 */
@RestController
@RequestMapping("/user")
public class LocalUserController {

    @Autowired
    private LocalUserServiceImpl localUserService;

    /**
     * 发现token为空（多个空）出现拿到用户信息情况进行修复
     */
    @IgnorePermission(name = "暂时忽略")
    @RequestMapping("/isLoginUser")
    public String isLoginUser(@RequestParam(name = "token") String token){
        return localUserService.isLoginUser(token);
    }



    /**
     * 通过userId获得用户信息
     */
    @IgnorePermission(name = "暂时忽略")
    @RequestMapping("/getUserInfoById")
    public List<Map<String, Object>> getUserInfoById(@RequestParam(name = "userId") String userId) {
        return localUserService.getUserInfoById(userId);
    }





    @IgnorePermission(name = "暂时忽略")
    @RequestMapping(value = "/login")
    public String login(@RequestParam("userName") String userName, @RequestParam("passWord") String passWord) {
        return localUserService.login(userName,passWord);
    }


}
